/*
 * 
 */
package org.spring.config.bus.controller;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * 
 * ClassName: EnvironmentController <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2019年10月12日 上午10:53:47 <br/>
 *
 * @author dengqian
 * @version
 * @since JDK 1.8
 */
@RestController
@RequestMapping
public class EnvironmentController {

    @GetMapping("/config/refreshAll")
    public String refresh() {
        CloseableHttpClient client = HttpClients.createDefault();
        HttpPost post = new HttpPost("http://127.0.0.1:8201/bus/refresh");
        HttpResponse response;
        try {
            response = client.execute(post);
            return EntityUtils.toString(response.getEntity());
        } catch (Exception e) {
            throw new RuntimeException("运行失败");
        }

    }

}
